import request from '@/utils/request'

export function getDepartments() {
  return request({
    url: '/company/department',
    method: 'get'
  })
}

// 获取部门负责人
export function getEmployeesSimple() {
  return request({
    url: '/sys/user/simple',
    method: 'get'
  })
}

// 获取部门详情
export function getDepartmentsDetail(id) {
  return request({
    url: `/company/department/${id}`,
    method: 'get'
  })
}

/**
 *
 * @param {code,introduce,manager,name,pid} data
 * @returns
 */
// 添加部门
export function addDepartments(data) {
  return request({
    url: '/company/department',
    method: 'post',
    data
  })
}

/**
 *
 * @param {code,introduce,manager,name,pid} data
 * @returns
 */
// 编辑部门
export function editDepartments(data) {
  return request({
    url: `/company/department/${data.id}`,
    method: 'PUT',
    data
  })
}

// 删除部门
/**
 * @description: 删除部门
 * @param {*} id 当前点击的操作按钮 所在的项的id
 * @return {*}
 */
export function delDepartment(id) {
  return request({
    url: `/company/department/${id}`,
    method: 'delete'
  })
}

